1. Field of the Invention
The present invention relates to operating systems for computers. More specifically, the present invention relates to a method and apparatus for looking up thread-specific computer system parameters from a centralized repository.
2. Related Art
The recent proliferation of computer networks such as the Internet has lead to the development of computer languages, such as the JAVA(trademark) programming language distributed by Sun Microsystems, Inc. of Palo Alto, Calif. (Sun, the Sun logo, Sun Microsystems, and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.) The Java programming language supports execution of platform-independent Java bytecodes, which can be transported across a computer network, such as the Internet, to remote computer nodes. These remote computer nodes include a xe2x80x9cJava virtual machinexe2x80x9d that is able to execute the Java bytecodes.
Java virtual machines typically support multiple threads of execution, thereby allowing a number of different bytecodes to execute concurrently. Unfortunately, existing Java virtual machines do not maintain certain types of thread-specific computer system configuration information. For example, a Java virtual machine provides only a single xe2x80x9cSystem.outxe2x80x9d variable specifying an output stream for screen output. This single System.out variable cannot be used for multiple threads that want to direct output to different destinations. This can pose a problem in implementing certain applications, such a chat server that maintains a plurality of different threads to converse with a plurality of different connections. Such a system is not practical to implement using a single System.out variable.
What is needed is a method and apparatus that provides a generic interface that allows individual threads to keep track of thread-specific computer system parameters.
One embodiment of the present invention provides a system that looks up thread-specific computer system parameters from a centralized repository. These thread-specific computer system parameters govern interactions between threads and components within a computer system. The system operates by receiving a request from a thread to look up a thread-specific computer system parameter. In response to this request, the system obtains a thread identifier associated with the thread, and uses the thread identifier to look up the thread-specific computer system parameter from the centralized repository of computer system parameters. Next, the system uses the thread-specific computer system parameter in performing an action for the thread related to operation of a computer system component. For example, the system may use the thread-specific computer system parameter to xe2x80x9cpower onxe2x80x9d or xe2x80x9cpower offxe2x80x9d a board within a server.
In one embodiment of the present invention, the centralized repository includes a primary hash table that is indexed by thread identifier. In a variation on this embodiment, the centralized repository further comprises a plurality of secondary hash tables, wherein the plurality of secondary hash tables are referenced by entries in the primary hash table. These secondary hash tables are indexed by parameter type.
The thread-specific computer system parameters stored in the centralized repository can specify a number of things. For example, a thread-specific computer system parameter can specify: an input stream through which the thread receives input; an output stream through which the thread directs output; a current directory location for the thread; or a credential that allows the thread to access hardware resources in the computer system.
One embodiment of the present invention operates within a service processor that supports a server running multiple instances of an operating system.
One embodiment of the present invention operates in concert with a Java virtual machine.
In one embodiment of the present invention, if the step of looking up the thread-specific computer system parameter fails, the system looks up the thread-specific computer system parameter using an identifier for a parent of the thread.